<template>
  <div class="rightsBox">
    <!-- 面包屑 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>

    <el-card class="box-card">
      <el-table :data="tableData" border style="width: 100%  margin-top:10px">
        <el-table-column
          type="index"
          width="50"
          label="#"
          align="center"
        ></el-table-column>
        <!-- prop为对应列内容的字段名 -->
        <el-table-column
          prop="authName"
          label="权限名称"
          align="center"
        >
        </el-table-column>
        <el-table-column prop="path" label="路径" align="center">
        </el-table-column>
        <el-table-column
          prop="level"
          label="权限等级"
          width="360"
          align="center"
        >
          <template slot-scope="scope">
            <el-tag :type="scope.row.level == 0 ? 'success' : scope.row.level == 1 ? '' : 'danger' ">{{ scope.row | level }}</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import { getRights } from "../../api/index";
export default {
  data() {
    return {
      tableData: [],
    };
  },
  methods: {
    async initGetRights() {
      let {
        data,
        meta: { msg, status },
      } = await getRights({ type: "list" });
      if(status != 200) return this.$message.error(msg)
      this.tableData = data;
    },
  },
  filters: {
    "level": function(val,filterParams) {
       switch (val.level) {
          case '0':
             return  '一级'
          case '1':
             return  '二级'
          default:
            return '三级'
          
       }
    }
  },
  created() {
    this.initGetRights();
  },
};
</script>

<style scoped>
.box-card {
  /* width: 1200px; */
  max-height: 800px;
  overflow: auto;
}
.rightsBox {
  padding-left: 20px;
}

.el-table {
  margin-top: 20px;
}
.el-breadcrumb {
  font-size: 12px;
  background-color: initial;
  margin-bottom: 0;
}
</style>
